import psycopg2
from pprint import pprint
import ConfigParser
conn = None
try:
	config = ConfigParser.RawConfigParser()
	config.read('/etc/ude/switch/database.ini')
	conn = psycopg2.connect("dbname='{0}' user='{1}' host='{2}' password='{3}'".format(config.get('Database','dbname'),config.get('Database','user'),config.get('Database','host'),config.get('Database','password')));
except:
	print "I am unable to connect to the database"

if __name__ == "__main__":
	print "[general]"
	print "attach = yes"
	print "format = wav"
	print "mailcmd=/usr/sbin/sendmail -t -f asterisk@cryingwolf.org"
	print "maxsilence = 10"
	print "envelope = yes"
	print "minmessage = 3"
	print "review = yes"
	print "saycid = yes"
	print "emailsubject = New Voice Message"
	print "serveremail = asterisk@cryingwolf.org"
	print "fromstring = ${VM_CALLERID}"
	print "emailbody = Dear ${VM_NAME},\\n\\nJust wanted to let you know you were left a message from ${VM_CIDNAME} (${VM_CIDNUM}) on ${VM_DATE}. You might want to check it out when you get a chance. \\n\\nThanks!"
	print ""
	print "[default]"
	
	
	
	
	c = conn.cursor()
	c.execute("""SELECT did,password,vmname,email,delete FROM t_vm;""")
	rows = c.fetchall()
	for row in rows:
		print "{0} => {1},{2},{3},,delete={4}".format(row[0],row[1],row[2],row[3],int(row[4]))
